<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 
 * @property int $plan_id 方案ID
 * @property int $listen_robot_id 监听微号id
 * @property int $room_id 转播群id
 * @property array $content 发送内容
 * @property array $msg_data 消息内容
 * @property int $status 状态：0=转发中 1=转发成功 2=转发失败
 * @property string $completed_at 完成时间
 * @property \Carbon\Carbon $created_at 转播时间
 * @property \Carbon\Carbon $updated_at 
 * @property-read null|ChRobot $robot 
 * @property-read null|ChRoom $room 
 */
class ChRoomBroadcastRecord extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_room_broadcast_record';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'plan_id', 'listen_robot_id', 'room_id', 'content', 'msg_data', 'status', 'completed_at', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'plan_id' => 'integer', 'listen_robot_id' => 'integer', 'room_id' => 'integer', 'content' => 'array', 'msg_data' => 'array', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function robot(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChRobot::class, 'id', 'listen_robot_id');
    }

    public function room(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChRoom::class, 'id', 'room_id');
    }
}
